<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:thSys="">
<div th:replace="admin/module/macros :: head('页面管理')"></div>
<body class="app sidebar-mini rtl">
	<main class="app-content">
	<div th:replace="admin/module/macros :: header"></div>
	<div th:replace="admin/module/macros :: sidebar"></div>
	<div class="app-title">
		<div>
			<h1>
				<i class="fa fa-book"></i>页面管理
			</h1>
		</div>
		<ul class="app-breadcrumb breadcrumb">
			<li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
			<li class="breadcrumb-item"><a href="/admin/page">页面管理</a></li>
			<li class="breadcrumb-item">所有页面</li>
		</ul>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="tile">
			<input type="hidden" id="articleId">
			<a href="/admin/page?status=0" th:style="${status==0} ? 'color: #000' : ''"><span>已发布(<th:block th:text="${published}"></th:block>)</span></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="/admin/page?status=1" th:style="${status==1} ? 'color: #000' : ''"><span>草稿(<th:block th:text="${draft}"></th:block>)</span></a>
				<div class="table-responsive">
					<table class="table table-striped table-bordered table-hover"
						id="article_table">
						<tr>
							<td>标题</td>
							<td>路径</td>
							<td>创建时间</td>
							<td>操作</td>
						</tr>
						<tr th:each="article,iterStat : ${info.list}">
							<td th:text="${#strings.abbreviate(article.articleTitle,20)}"></td>
							<td th:text="${#strings.abbreviate(article.articleUrl,20)}"></td>
							<td th:text="${#dates.format(article.articleNewstime,'yyyy/MM/dd HH:mm:ss')}"></td>
							<td th:switch="${article.articleStatus}">
								<th:block th:case="0">
									<a th:href="@{'/'+${article.articleUrl}}" th:target="_blank" class="btn btn-sm btn-outline-primary">查看</a>
									<a th:href="@{/admin/page/edit(article_id=${article.id})}"
										class="btn btn-sm btn-outline-info">编辑</a>
										<button th:onclick="'javascript:showModel('+${article.id}+')'"
										class="btn btn-sm btn-outline-danger">彻底删除(不可逆)</button>
								</th:block>
								 <th:block th:case="1">
									<a th:href="@{/admin/page/edit(article_id=${article.id})}"
										class="btn btn-sm btn-outline-primary">编辑</a>
									<button th:onclick="'javascript:restore('+${article.id}+')'" class="btn btn-sm btn-outline-info">发布</button>
									<button th:onclick="'javascript:showModel('+${article.id}+')'"
										class="btn btn-sm btn-outline-danger">彻底删除(不可逆)</button>
								</th:block>
								</td>
						</tr>
						<tr th:unless="${info.list.total} != 0">
							<td th:text="暂无页面" th:attr="colspan='7',align='center'" ></td>
						</tr>
					</table>
				</div>
				<div th:replace="admin/module/macros :: pageArticle(${info},${status})"></div>
			</div>
		</div>
	</div>
	</main>
	<div th:replace="admin/module/macros :: remove"></div>
	<div th:replace="admin/module/macros :: comm"></div>
	<script type="text/javascript">
	//显示询问框
	function showModel(id) {
		$("#articleId").val(id);
		$("#removeModal").modal();
	}
	//删除
	function remove(){
		window.location.href = "/admin/page/remove?id="
			+ $("#articleId").val();
	}
	
	//修改文章为发布状态
	function restore(id){
		$.ajax({
			url:"/admin/article/restore",
			type:"post",
			data:{id:id},
			dataType:"json",
			success:function(data){
				if(data.flag==true){
					window.location.reload();
				}else{
					showMsg(data.msg,"error","3000");
				}
			}
		});
	}
	</script>
</body>
</html>